// stores/counter.ts
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0,
    name: 'User',
    lastName: null as string | null
  }),
  actions: {
    increment() {
      this.count++
    },
    setLastName(name: string) {
      this.lastName = name;
    }
  },
  // 启用持久化
  persist: {
    storage: sessionStorage, // 使用sessionStorage
  }
})